package com.xique.park.controller.client.web.service.service.impl;


import com.xique.common.core.web.domain.AjaxResult;
import com.xique.park.cloud.http.HttpClient;
import com.xique.park.cloud.http.HttpMethod;
import com.xique.park.cloud.http.HttpRequest;
import com.xique.park.cloud.http.HttpResponse;
import com.xique.park.controller.client.web.service.service.IWxAppPlatApi;
import org.springframework.stereotype.Service;

/**
 * @author taojc
 * @date 2022-08-25
 */
@Service
public class IWxAppPlatApiImpl implements IWxAppPlatApi {

    private String VZ_BASE_URL = "https://open.vzicloud.com";
    private String VZ_ACCESSKEY_ID = "Kv3CG8qi62C5500hPUh2Dz65TE47g3ul";
    private String VZ_ACCESSKEY_SECRET = "v4cXdSsAq7bxpkEhscVmH4fa75vMXn0P";

    /**
     * @param code
     * @description: 获取臻识远程相机
     * @author taojc
     * @date: 2022/8/25
     */
    @Override
    public AjaxResult getAppDeviceWebUrlSn(String code) {

        HttpClient client = new HttpClient(VZ_BASE_URL, VZ_ACCESSKEY_ID, VZ_ACCESSKEY_SECRET);
        HttpRequest request = new HttpRequest(HttpMethod.GET, "/openapi/v1/stp/user/devices/pdns/web");
        request.addParam("sn", code);
        request.addParam("type", "text");
        HttpResponse response = client.doRequest(request);
        int status = response.getStatus();
        if (status == 200) {
            System.out.println("请求成功!");
            return AjaxResult.success(response.getBodyStr());
        } else {
            System.out.println("请求失败!");
            return AjaxResult.error("请求失败。失败原因：" + response.getBodyStr());
        }
    }
}
